package org.lc.stk.model.baseInfo;

import org.hibernate.annotations.Comment;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

/**
 * 专业信息
 */
@Entity
@Table(name = "major")
@Comment("专业信息")
public class Major {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @NotBlank(message = "专业编码不能为空")
    @Size(max = 50, message = "专业编码不能超过50个字符")
    @Column(unique = true, nullable = false)
    @Comment("专业编码")
    private String code;

    @NotBlank(message = "专业名称不能为空")
    @Size(max = 100, message = "专业名称不能超过100个字符")
    @Column(nullable = false)
    @Comment("专业名称")
    private String name;

    @Column(nullable = false)
    @Comment("是否启用")
    private Boolean enabled = true;

    @Column(columnDefinition = "boolean default false")
    @Comment("是否删除")
    private Boolean isDeleted = false;

    @Column
    @Comment("排序号")
    private Integer orderNum = 0;

    @Size(max = 500, message = "备注不能超过500个字符")
    @Column
    @Comment("备注")
    private String remark;



    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * 检查专业是否可用
     */
    public boolean isEnabled() {
        return enabled && !isDeleted;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Major)) return false;
        Major major = (Major) o;
        return getId() != null && getId().equals(major.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }

    @Override
    public String toString() {
        return "Major{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", enabled=" + enabled +
                '}';
    }
}
